package com.yigo.prc.infra.repo.converter;

import com.yigo.framework.snapshot.SnapshotConverter;
import com.yigo.prc.domain.spu.entity.PrcSpu;
import com.yigo.prc.infra.repo.dataobject.PrcSpuPO;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author chenzl
 */
@Mapper
public interface PrcSpuDmo2PoConverter extends SnapshotConverter {
    PrcSpuDmo2PoConverter INSTANCE = Mappers.getMapper(PrcSpuDmo2PoConverter.class);

    @Mapping(target = "category.categoryId", source = "categoryId")
    @Mapping(target = "category.categoryName", source = "categoryName")
    @Mapping(target = "unit.unitCode", source = "unitCode")
    @Mapping(target = "unit.unitName", source = "unitName")
    @Mapping(target = "brand.brandCode", source = "brandCode")
    @Mapping(target = "brand.brandName", source = "brandName")
    PrcSpu toDmo(PrcSpuPO dmo);

    @InheritInverseConfiguration(name = "toDmo")
    PrcSpuPO toPO(PrcSpu dmo);
}
